import Vue from 'vue';
import Vuex from 'vuex';

Vue.use(Vuex);

const store = new Vuex.Store({
	state: {
		//ip: "http://4scafe.carnettong.com",// 双胜IP
		// ip: "http://192.168.0.123:9088",// 振豪
		// ip: "http://192.168.0.180:9010",// 双胜IP
		ip: "http://carnt.carnettong.com:8088",
		cityName:"深圳",
		isLocation:false,
		carId:"23835",// 默认车辆id
		lgnLat:"",
		defaultCatAllInfo:{}// 默认车辆的所有信息
	},
	getters: {
		getIp: (state) => state.ip,
		getJumpIp: (state) => state.jumpUrl,// 不知道干啥的 可以remove
		getTodos: (state) => state.todos,// test 可以remove
		getIsLocation: (state) => state.isLocation,
		getCityName: (state) => state.cityName,
		getLgnLat: (state) => state.lgnLat,//经纬
		getCarId: (state) => state.carId,//取默认车辆id
		getDefaultCatAllInfo: (state) => state.defaultCatAllInfo// 默认车辆的所有信息
	},
	mutations: {
		CHANGE (state, platform) {
			state.todos = platform;
		},
		alterCity (state,selectCity){//改变当前选择的城市
			state.cityName=selectCity;
		},
		alterLocation (state,Location){//设置是否定位过
			state.isLocation=Location;
		},
		alterMess (state,id){// 改变默认车辆
			state.carId=id;
		},
		alterLgnLat (state,str){//改变经纬度
			state.lgnLat=str;
		},
		changeDefaultCatAllInfo (state, platform){
			state.defaultCatAllInfo = platform;
		}
	},
	actions: {
		setChange ({commit}, platform) {
			commit('CHANGE', platform);
		},
		setCarId ({commit}, platform) {// 改变默认车辆
			commit('alterMess', platform);
		},
		setDefaultCatAllInfo ({commit}, platform) {// 改变默认车辆所有信息
			commit('changeDefaultCatAllInfo', platform);
		},
		setLocation({commit}, platform) {// 改变默认车辆所有信息
			commit('alterLocation', platform);
		}
	}
})
export default store;